package org.game.msgBuilder;

import java.util.ArrayList;
import java.util.List;

import org.bean.SourceChatMsg;
import org.game.protobuf.s2c.S2CChatMsg;
import org.game.protobuf.s2c.S2CChatMsg.ChatInfo;

/**
 * @author : DengYing
 * @CreateDate : 2017年11月3日 下午3:08:36
 * @Description ：Please describe this document
 */
public class ChatMsgBuilder {
	private ChatMsgBuilder() {
	}

	private static ChatMsgBuilder ME = new ChatMsgBuilder();

	public static ChatMsgBuilder me() {
		return ME;
	}

	public ChatInfo builderChatInfo(SourceChatMsg msg) {
		ChatInfo.Builder builder = ChatInfo.newBuilder();
		builder.setChannel(msg.getChannel());
		builder.setFun(msg.getFun());
		builder.setContent(msg.getContent());
		builder.setPid(msg.getSourcePid());
		builder.setPname(msg.getSourceName());
		builder.setLvl(msg.getLvl());
		builder.setHelpFightHeroCid(msg.getHelpFightHeroCid());
		return builder.build();
	}
	
	public List<ChatInfo> builderChatInfo(List<SourceChatMsg> msgs) {
		List<ChatInfo> infos = new ArrayList<>(msgs.size());
		for (SourceChatMsg msg : msgs) {
			infos.add(builderChatInfo(msg));
		}
		return infos;
	}

	public S2CChatMsg.ChatMsg buildChatMsg(int time){
		S2CChatMsg.ChatMsg.Builder builder = S2CChatMsg.ChatMsg.newBuilder();
		builder.setTime(time);
		return builder.build();
	}
}
